// layout
import Footer from "@/layout/footer/index.vue";
import Header from "@/layout/header/index.vue";

//#region 自动导入模块路由
const files = require.context("./modules", false, /\.js$/);
const modules = [];

files.keys().forEach((key) => {
    modules.push(files(key).default || files(key));
});
//#endregion

const routes = [
    {
        path: "/login",
        name: "login",
        meta: {
            title: "登录",
            isOpen: true,
        },
        component: () => import("@/views/login/index.vue"),
    },
    {
        path: "/",
        name: "fotterMain",
        redirect: "/home",
        component: Footer,
        children: [
            {
                path: "home",
                name: "home",
                meta: {
                    title: "系统概览",
                },
                component: () => import("@/views/home/dashboard.vue"),
            },
            {
                path: "salary",
                name: "salary",
                meta: {
                    title: "薪资酬劳"
                },
                component: () => import("@/views/salary/list.vue"),
            },
            {
                path: "personCenter",
                name: "personCenter",
                meta: {
                    title: "个人中心",
                },
                component: () => import("@/views/personCenter/index.vue"),
            },
        ],
    },
    {
        path: "/",
        name: "headerMain",
        redirect: "/home",
        component: Header,
        children: [...modules],
    },
    {
        path: "/redirect",
        name: "redirect",
        meta: {
            title: "Redirect demo",
            hideHeader: true,
            isOpen: true,
        },
        component: () => import("@/views/redirect/index.vue"),
    },
];

export default routes;
